package com.service.impl;

import com.mapper.StartstopselfMapper;
import com.pojo.Startstopself;
import com.service.StartStopSelfService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service("startStopSelfService")
public class StartStopServiceSelfImpl implements StartStopSelfService {
    @Resource
    private StartstopselfMapper startstopselfMapper;
    @Override
    public List<Startstopself> selectStartStopByOwnerId(Integer ownerid) {
        List<Startstopself> startstops = startstopselfMapper.selectStartStopByOwnerId(ownerid);
        return startstops;
    }

    @Override
    public int addStartStop(Startstopself startstopself) {
        Date date = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        startstopself.setStarttime(formatter.format(date));
        int i = startstopselfMapper.addStartStop(startstopself);
        return i;
    }

    @Override
    public int deleteStartStopById(Integer id) {
        int i = startstopselfMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public Startstopself selectStartStopByParkLotId(Integer parklotid) {
        Startstopself startstopself = startstopselfMapper.selectStartStopByParkLotId(parklotid);
        return startstopself;
    }
}
